home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6855 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  45 lines

  1. Path: sun001.spd.dsccc.com!spd!jmccarty
  2. From: jmccarty@spd.dsccc.com (Mike McCarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Watch out!  C "gotcha!"
  5. Date: 15 Feb 1996 19:34:52 GMT
  6. Organization: DSC Communications Corporation, Plano, Texas USA
  7. Message-ID: <4g01ss$hgj@sun001.spd.dsccc.com>
  8. References: <4fthhh$7th@blackice.winternet.com>
  9. NNTP-Posting-Host: aplo139.spd.dsccc.com
  10.  
  11. In article <4fthhh$7th@blackice.winternet.com>,
  12. Michael Schwarz <mschwarz@winternet.com> wrote:
  13. )Many of you may already know this, but even after ten years of coding
  14. )in C, this took my by surprise at first.  A co-worker and I were looking
  15. )at some library C code where I work and we noticed that the "default"
  16. )clause of one of the switches was misspelled as "defalt."
  17. )
  18. )He said, "This must have been changed since it was last compiled."
  19. )
  20. )"What the heck, we're in development.  Run make."
  21.  
  22. [stuff cut]
  23.  
  24. )The thing that scares me the most about this is that either I've never before
  25. )made this particular mistake or for the last ten years I've been leaving
  26. )behind a number of ticking code bombs...
  27.  
  28. I know of no way to make a compiler catch spelling mistakes on labels
  29. except by doing what Pascal does - force declaration of labels. The
  30. exact same problem (only worse) occurs in Fortran where misspelled
  31. variables "declare themselves". There is no solution except to require
  32. declarations.
  33.  
  34. This is C. C is a warty, ugly language. The best you can do is learn to
  35. live with it, or move on to better languages. In this case, learning to
  36. live with C includes doing careful code inspections. Add looking for
  37. misspelled labels to your list of things to look for during inspection.
  38.  
  39. Mike
  40.  
  41. ----
  42. char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
  43.  
  44. I don't speak for DSC.         <- They make me say that.
  45.